<#import "/macro.ftl" as m>
<@m.page_header title='后台' />
<div id="page-content-wrapper">

<div id="page-title">

    <h3>
        <#if presell>修改排期预售<#else>添加排期预售</#if>
    </h3>
 
</div>
<div class="pad10A">
<#if presell> 
<form id="demo-form1" action="/presell/update/${presell.id}" class="col-md-12" method="POST">
<#else>
<form id="demo-form1" action="/presell/add" class="col-md-12" method="POST">
</#if>

	<#if presell>
	<input type="hidden" name="id" value="${presell.id}"/>
	</#if>
	
	<div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            产品名称:
	        </label>
	    </div>
		    <div class="form-input col-md-6">
		        <input type="text" id="name" name="name" data-trigger="change" class="parsley-validated" value="${presell.name}">
		        <font size="2" color="red">产品名称若不填，取默认值。产品号请用"%s"表示</font>
		    </div>
    </div> 
    
    <div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            产品期限:
	        </label>
	    </div>
		    <div class="form-input col-md-3">
		        <input type="text" id="term" name="term" data-trigger="change" class="parsley-validated" value="${presell.term}">
		        <font size="2" color="red">产品期限若不填，取默认值。</font>
		    </div>
    </div>
	
   <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                产品类别:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-2">
        	<select id="category" name="category">
		    	<option value="MONTH" <#if presell.category == 'MONTH'>selected</#if> >月享</option>
		    	<option value="QUARTER" <#if presell.category == 'QUARTER'>selected</#if> >季享</option>
		    	<option value="HALF_A_YEAR" <#if presell.category == 'HALF_A_YEAR'>selected</#if> >双季汇</option>
		    	<option value="YEAR" <#if presell.category == 'YEAR'>selected</#if> >年享</option>
		    	<option value="CURRENT" <#if presell.category == 'CURRENT'>selected</#if> >钱滚翻</option>
		    </select>
        </div>
    </div>
    
    <div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="financialAsset">
	            金融资产:
	        </label>
	    </div>
		<#if presell.id??>
			<div class="form-label col-md-8">
				<#if presell.financialAsset??>
					<label>${presell.financialAsset.name} 到期日：${presell.financialAsset.dueDate?string('yyyy-MM-dd')}</label>
				</#if>
			</div>
		<#else>
	    	<div class="form-input col-md-8">
		    	<select id="financialAsset" name="financialAsset.id">
		        	<option value="" <#if presell.financialAsset??==false>selected</#if> >金融资产产品，请选择相应的金融资产。不是，则不选。</option>
		        	<#list financialAssets as financialAsset>
		        		<option value="${financialAsset.id}" <#if presell.financialAsset.id == financialAsset.id >selected</#if>>
		        			库存：${financialAsset.inventory?string(",##0.00")}元 到期日：${financialAsset.dueDate?string('yyyy-MM-dd')} ${financialAsset.name} 资产金额：${financialAsset.amount?string(",##0.00")}元
		        		</option>
		        	</#list>
		        </select>
		     </div>
		</#if>
	</div>
	
	<div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            模板类别:
	        </label>
	    </div>
	    <div class="form-input col-md-2">
	        <select id="typeSelect" name="typeId">
	            <option value="">无分类</option>
	        <#list productTypeList as type>
	            <#if type.id == presell.producttype.id>
	                <option value="${type.id}" selected="selected">${type.name}</option>
	            <#else>
	                <option value="${type.id}">${type.name}</option>
	            </#if>
	        </#list>
	        </select>
	    </div>
	</div>
	
	<div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            活动:
	        </label>
	    </div>
	    <div class="form-input col-md-6">
	        <select id="activitySelect" name="activitys" multiple="" class="chosen-select">
	        <#list saleActivityList as activity>
	            <option value="${activity.id}" <#list presell.activitys?split(",") as aid><#if aid==activity.id>selected</#if></#list>>${activity.name}</option>
	        </#list>
	        </select>
	    </div>
	</div>
    
    <div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            总金额:
	            <span class="required">*</span>
	        </label>
	    </div>
	    <#if presell.id??>
		    <div class="form-label col-md-4">
		        <label>${presell.totalAmount}元</label>
		    </div>
		<#else>
		    <div class="form-input col-md-2">
		        <input type="text" id="totalAmount" name="totalAmount" data-type="number" data-trigger="change"
		               data-required="true" class="parsley-validated" value="${presell.totalAmount}">
		    </div>
		    <div class="col-md-2">元</div>
		</#if>
    </div> 
    <div class="row">
		<div class="col-md-6">
			<div class="form-row">
	            <div class="form-label col-md-4">
	            </div>
	            <div class="form-checkbox-radio col-md-8">
		            <input type="checkbox" name="rookie" id="rookie" <#if presell.rookie >checked</#if> >
		            <label for="rookie">新手标</label>
	            </div>
	    	</div>
		</div>
	</div>
    <div class="divider"></div>
    <div class="form-row">
       <input type="hidden" name="superhidden" id="superhidden">
	   <div class="form-input col-md-10 col-md-offset-2">
		    <a href="javascript:;" class="btn medium primary-bg radius-all-4 col-md-2" id="demo-form-2-valid">
		        提交
		    </a>
	    </div>
    </div>
</form>
</div>
</div>



<script type="text/javascript">
$(function(){
		$("#demo-form-2-valid").click(function(){
			$('#demo-form1').parsley('validate');
	    	$('#demo-form1').trigger('submit');
		});
});

</script>